//
// Created by lfm on 25-4-18.
//
#include <iostream>
#include <string>
using namespace std;

//字符串的查找和替换

//1.查找
void test01()
{
    string str1;
    str1 = "abcdefghigk";
    cout << (int)str1.find("de") << endl;
    int ret = str1.find("de");//这是子串出现的下标

    ret = str1.rfind("de");
    cout << ret << endl;
}
//2.替换
void test02()
{
    string str1 = "abcdefg";

    //从1号位置起3个字符替换为"1111111"
    str1.replace(1, 3, "1111111");

    cout << str1 << endl;
}

int main()
{
    // test01();
    test02();
    return 0;
}